<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>配件查询及状态转换</title>
<%@ include file="../include/common.jsp"%>
<%@ include file="../include/table.jsp"%>
<%@ include file="../include/jbox.jsp"%>
<%@ include file="../include/crontab.jsp"%>

</head>

<style>
.probebutton {
	background: #f9f9fb;
	border: 1px solid #d8dadc;
	padding: 2px 4px 2px 4px;
	margin-right: 2px;
	cursor: pointer;
}

.ok {
	font-weight: bold;
	color: black;
}

.on {
	font-weight: bold;
	color: blue;
}

.down {
	font-weight: bold;
	color: green;
}

.mt {
	font-weight: bold;
	color: pink;
}

.scrap {
	font-weight: bold;
	color: red;
}
</style>

<script type="text/javascript">
	var oTable;
	$().ready(function(){
		//getPeijianList();
	});
	
	function fnFormatDetails ( oTable, nTr ) {  
			var sOut = '<table cellpadding="5" name="propertyTbl" cellspacing="0"  border="1px solid #e7e6e7" style="padding-left:130px;">'; 
			 sOut+='<tr><td>上车日期：'+oTable.fnGetData( nTr ).ondate;
			 sOut += '</td></tr>';   
			 sOut+='<tr><td>下车日期：'+oTable.fnGetData( nTr ).downDate;
			 sOut += '</td></tr>';   
			 sOut+='<tr><td>修程：'+oTable.fnGetData( nTr ).xiuc;
			 sOut += '</td></tr>';   
			 sOut+='<tr><td>检修情况：'+oTable.fnGetData( nTr ).result;
			 sOut += '</td></tr></table>';   
			 return sOut; 
     } 
	
	
	
	function getPeijianList(){
		oTable=$("#message_list").dataTable({
			"bScrollCollapse":false,
			"bProcessing": true, 
			"bServerSide": true,
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/simple/peijian!reslist.action',
			"bPaginate": true,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			"sPaginationType": "full_numbers",
			"sDom":'rt <"bottom"flpi>',
			"iDisplayLength":20,
			"aLengthMenu": [[20], [20]],
			"aoColumns" : [
				{"mDataProp":"op","":"center","bSortable": false},
				{"mDataProp":"id","bVisible":false},
				{"mDataProp":"name","bSortable": false},
				{"mDataProp":"code","bSortable": false},
				{"mDataProp":"type","bSortable": false},
				{"mDataProp":"vendor","bSortable": false}
			],
			 "oLanguage": {
	 				"sLengthMenu": "每页 _MENU_ 条",
	 		 		"sZeroRecords": "没有找到记录",
					"sInfo": "当前从 _START_ 到 _END_ 条,共 _TOTAL_ 条记录", 
					"sInfoEmpty": "当前从 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
					"oPaginate":{"sFirst":"首页","sPrevious":"上一页","sNext":"下一页","sLast":"尾页"}	
			},
			 "fnServerParams":function(aoData){
			    	aoData.push({'name':'stype','value':$("#stype").val()});
			    	aoData.push({'name':'sname','value':$("#sname").val()});
			    	aoData.push({'name':'sstatus','value':$("#sstatus").val()});
			 }
		});
	}
	
	//点击查询
	function search(){
		var oTable = $("#message_list").dataTable();
			 oTable.fnPageChange("first",true);
	}
	
	function showMenuUserTree() { 
		var cityObj = $("#operatorUserName");
		var cityOffset = cityObj.offset();
		$("#userTreeContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
		$("body").bind("mousedown", onBodyDownUserTree);
	}
	
	function hideMenuUserTree() {
		$("#userTreeContent").fadeOut("fast");
	}
	
	function onBodyDownUserTree(event) {
		if (!(event.target.id=="userTreeContent"||event.target.id == "operatorUserName" || event.target.id == "operatorUserId" || $(event.target).parents("#userTreeContent").length>0)) {
			hideMenuUserTree();
		}
	}
	
	function userNodeClick(e, treeId, treeNode) {
		if(treeNode.ntype==2){ //部门不能被选择
			return;
		}
		var parent = treeNode.getParentNode();
		$("input[name='operatorUserId']").attr("value", treeNode.id);
		$("input[name='operatorUserName']").attr("value",treeNode.name);
		$("input[name='operatorUserName']").blur();
		hideMenuUserTree();
	}
	
	function opraterChangeEvent(){
		refTable();
	}
	
	//刷新table
	function refTable(pageIndex){
		var oTable=$('#message_list').dataTable();
		if(pageIndex==null||pageIndex=='undefined'){
			var oSettings =oTable.fnSettings();
			//索引页从0开始
			pageIndex=oSettings._iDisplayStart/oSettings._iDisplayLength;
		}
		oTable.fnPageChange(pageIndex);
	}
	
	
	
	function goscrap(id){
		location.assign("${pageContext.request.contextPath}/peijian/peijian!goscrap.action?id="+id);
	}
	
	function gomt(id){
		location.assign("${pageContext.request.contextPath}/peijian/peijian!gomt.action?id="+id);
	}
	
	function goup(id){
		location.assign("${pageContext.request.contextPath}/peijian/peijian!goup.action?id="+id);
	}
	
	function godown(id){
		location.assign("${pageContext.request.contextPath}/peijian/peijian!godown.action?id="+id);
	}
	
	function gook(id){
		$.ajax({
			url : '${pageContext.request.contextPath}/peijian/peijian!gook.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				id:id
			},
			success : function(data) {
				refTable();
			}
		});
	}
	
	function del(id){
		$.ajax({
			url : '${pageContext.request.contextPath}/peijian/peijian!delete.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				id:id
			},
			success : function(data) {
			    window.setTimeout(function () { $.jBox.tip('配件删除成功', 'success'); }, 100);
				refTable();
			}
		});
	}
	
	//新增一个设备
	function add(){
		location.assign("${pageContext.request.contextPath}/simple/simple!addresource.action");
	}
	
	</script>
<body style="100%">
	<!-- 高级搜索区 -->
	<div class="column search-bar no"
		style="display:block; width:98%;margin-left:8px;" id="search-bar">
		<div class="search-bar-bottom">
			<label class="label-text">设备IP：</label> <input type="text" id="stype"
				name="stype" /> <label class="label-text">设备名称：</label> <input
				type="text" id="sname" name="sname" /> <label class="label-text">设备类型：</label>
			<select
				style="width:150px; height:21px;background-color: #fff;border:1px solid gray;"
				id="sstatus" name="sstatus">
				<option value="">全部</option>
				<option value="0">交换机</option>
				<option value="1">防火墙</option>
				<option value="2">路由器</option>
				<option value="3">主机</option>
				<option value="4">其它</option>
			</select> 
			<input class="sousuo" type="button" name="" value="查询"
				onclick="search()" />
				
			<input class="sousuo" type="button" name="" value="新增设备"
				onclick="add()" />
		</div>
	</div>
	<!-- @end高级搜索区 -->

	<div style="width:99%;margin-left:8px;">
		<table id="message_list" cellpadding="0" cellspacing="0" border="0"
			class="display no">
			<thead>
				<tr>
					<th width="1%">操作</th>
					<th width="2%">ID</th>
					<th width="3%">名称</th>
					<th width="3%">编码</th>
					<th width="3%">类型</th>
					<th width="3%">IP</th>
				</tr>
			</thead>
		</table>
	</div>

</body>
</html>